import { Color } from "cc";
import * as fgui from "fairygui-cc";
import { stat } from "fs";
import { common } from "../../../../proto/protoCmd";
export class Grid extends fgui.GButton {
    private graph: fgui.GGraph;
    private ctrl_state: fgui.Controller;
    private clip: fgui.GMovieClip;
    public enumstate: number = 0;//0空 1身 2头
    protected onConstruct(): void {
        this.graph = this.getChild("graph");
        this.ctrl_state = this.getController("ctrl_state");
        this.clip = this.getChild("clip");
        this.clip.visible = false;
    }
    public get state(): number {
        return this.ctrl_state.selectedIndex;
    }
    public setColor(): void {
        this.graph.color = new Color(0, 204, 255, 255);
    }
    public setColor2(): void {
        this.graph.color = new Color(51, 255, 102, 255);
    }
    // public setColor3(): void {
    // }
    public setColor4(): void {
        this.graph.color = new Color(255, 0, 0, 0);
    }
    public setCtrlState(state: number): void {
        this.ctrl_state.selectedIndex = state;
        switch (state) {
            case 2:
                this.graph.color = new Color(255, 0, 0, 100);
                break;
            case 3:
                this.title = `空`;
                this.graph.color = new Color(255, 255, 255, 255);
                break;
            case 4:
                this.title = `身`;
                this.graph.color = new Color(0, 255, 0, 255);
                this.clip.visible = true;
                this.clip.setPlaySettings(0, -1, 5, 0, () => { this.clip.visible = false; });
                break;
            case 5:
                this.title = `头`;
                this.graph.color = new Color(255, 0, 255, 255);
                this.clip.visible = true;
                this.clip.setPlaySettings(0, -1, 5, 0, () => { this.clip.visible = false; });
                break;
            case 7:
                this.title = `旗`;
                this.graph.color = new Color(0, 204, 255, 255);
                break;
        }
    }
}